package com.dianxin.smartpark.manager.order.impl;

import com.chinatelecom.response.common.CommonResponseBody;
import com.chinatelecom.response.utils.BeanUtil;
import com.chinatelecom.response.utils.ResponseBodyWrapperUtil;
import com.dianxin.smartpark.dao.dataobject.order.SmartParkOrderRecord;
import com.dianxin.smartpark.dao.mapper.order.SmartParkOrderRecordMapper;
import com.dianxin.smartpark.manager.order.ISmartParkOrderRecordService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 工单处理记录业务层处理
 * 
 * @author chenjiasong
 * @date 2021-07-22
 */
@Service
public class ISmartParkOrderRecordServiceImpl implements ISmartParkOrderRecordService
{
    private final static Logger logger = LoggerFactory.getLogger(ISmartParkOrderRecordServiceImpl.class);
    @Resource
    private SmartParkOrderRecordMapper smartParkOrderRecordMapper;


    /**
     * 新增工单处理记录
     * @param tenantId  工单编号
     * @param handlerStatus   处理状态
     * @param handlerUser   处理人
     * @param busiId   业务id
     * @param busiType  业务类型
     * @param nodeType  节点类型   1处理  2抄送
     * @param nodeName  节点名
     * @return
     */
    @Override
    public int insertSmartParkOrderRecord(String tenantId, int handlerStatus, String handlerUser, long busiId, int busiType, int nodeType,String nodeName,String remark)
    {
        SmartParkOrderRecord smartParkOrderRecord = new SmartParkOrderRecord();
        smartParkOrderRecord.setTenantId(tenantId);
        smartParkOrderRecord.setHandlerStatus(handlerStatus);
        smartParkOrderRecord.setHandlerUser(handlerUser);
        smartParkOrderRecord.setBusiType(busiType);
        smartParkOrderRecord.setBusiId(busiId);
        smartParkOrderRecord.setNodeType(nodeType);
        smartParkOrderRecord.setNodeName(nodeName);
        smartParkOrderRecord.setRemark(remark);
        smartParkOrderRecord.beforeInsert(handlerUser);
        return smartParkOrderRecordMapper.insertSelective(smartParkOrderRecord);
    }

    /**
     * 修改工单处理记录
     * @param id  记录id
     * @param handlerStatus   处理状态
     * @return
     */
    @Override
    public int updateSmartParkOrderRecord(long id, int handlerStatus)
    {
        SmartParkOrderRecord smartParkOrderRecord = new SmartParkOrderRecord();
        smartParkOrderRecord.setId(id);
        smartParkOrderRecord.setHandlerStatus(handlerStatus);
        smartParkOrderRecord.beforeUpdate();
        return smartParkOrderRecordMapper.updateByPrimaryKeySelective(smartParkOrderRecord);
    }

}
